import request from '@/utils/axios'
import type { dataList, codeNull, menuDataInterface } from './type'
enum API {
  ALLPERMISSION_URL = '/admin/acl/permission',
  ADDMENU_URL = '/admin/acl/permission/save',
  UPDATE_URL = '/admin/acl/permission/update',
  DELETEMENU_URL = '/admin/acl/permission/remove/',
}
export const reqAll = () => request.get<any, dataList>(API.ALLPERMISSION_URL)
export const reqAddPer = (val: menuDataInterface) => {
  if (val.id) {
    return request.put<any, codeNull>(API.UPDATE_URL, val)
  } else {
    return request.post<any, codeNull>(API.ADDMENU_URL, val)
  }
}
export const reqDel = (id: number) =>
  request.delete<any, codeNull>(API.DELETEMENU_URL + id)
